<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>工厂模式 (Factory Pattern)</title>
    <link href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <!-- popper.min.js 用于弹窗、提示、下拉菜单 -->
    <script src="https://cdn.bootcss.com/popper.js/1.14.2/umd/popper.min.js"></script>
    <script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</head>

<body>
    <div class="container">
        <header>
            <h1 class="text-center">工厂模式 (Factory Pattern)</h1>
        </header>
        <p>创建者模式处理对象创建. 它的目标是提供一个比直接创建对象更好的替代方案. </p>
        <p>
            Creational design patterns deal with an object creation. The aim of a creational design pattern is to provide better alternatives
            for situations where a direct object creation (which in Python happens by the __init__() function) is not convenient.
        </p>
        <p>在工厂模式中，客户端请求一个对象，而不知道对象来自哪里（也就是说，哪个类被用来生成对象）。工厂背后的理念是简化一个对象的创建。
            如果通过一个中心函数来完成，就更容易跟踪哪些对象被创建，而不是让客户端使用直接类实例化来创建对象.
            工厂通过将创建对象的代码与使用它的代码分离，从而降低了维护应用程序的复杂性.
        </p>
        <p>
            In the Factory design pattern, a client asks for an object without knowing where the object is coming from (that is, which
            class is used to generate it). The idea behind a factory is to simplify an object creation. It is easier to track
            which objects are created if this is done through a central function, in contrast to letting a client create
            objects using a direct class instantiation [Eckel08, page 187]. A factory reduces the complexity of maintaining
            an application by decoupling the code that creates an object from the code that uses it [Zlobin13, page 30].
        </p>
        <p>工厂通常有两种形式：
            工厂方法，它是一种方法（或用python术语来说，是一个函数），它返回每个输入参数的不同对象;
            抽象工厂，它是一组工厂方法用来创建一个相关产品的家族</p>
        <p>
            Factories typically come in two forms: the Factory Method, which is a method (or in Pythonic terms, a function) that returns
            a different object per input parameter; the Abstract Factory, which is a group of Factory
            Methods used to create a family of related products.
        </p>
    </div>
</body>

</html>